#include "simclist.h"
#include <arpa/inet.h>

#ifndef  simclist_impl
#define  simclist_impl



struct elem_file {
   char* nome;
   list_t* lista_peer;
};

typedef struct elem_file elem_file_t;


struct elem_superpeer {
	in_addr_t ip;
	int peer_number;
};

typedef struct elem_superpeer elem_superpeer_t;

struct elem_ip_ping {
	in_addr_t ip;
	double ping_time;
};

typedef struct elem_ip_ping elem_ip_ping_t;



int string_seeker(const void *a, const void *b);                // NAME FILE LIST
void *element_serializer_string(const void *restrict el, uint32_t *restrict serializ_len);
void *element_unserializer_string(const void *restrict data, uint32_t *restrict data_len);

int peer_comparator(const void *a, const void *b);       // SUPERPEER LIST
int superpeer_ip_seeker(const void *a, const void *b);
size_t list_superpeer_meter(const void *el);
void *element_serializer_superpeer_list(const void *restrict el, uint32_t *restrict serializ_len);
void *element_unserializer_superpeer_list(const void *restrict data, uint32_t *restrict data_len);
void add_superpeer(list_t* list,in_addr_t ip);
void delete_superpeer(list_t* list,in_addr_t ip);
void update_peer_number(list_t* list,in_addr_t ip,int peer_number );
void print_superpeer_list(list_t *list);
int ip_comparator(const void *a, const void *b);

int string_file_comparator(const void *a, const void *b);   // FILE LIST
int string_file_seeker(const void *el, const void *indicator);
int ip_file_seeker(const void *a, const void *b);
size_t list_file_meter(const void *el);
void add_file(list_t *list,char *nome,in_addr_t ip);
void delete_file(list_t *list,char *nome,in_addr_t ip);
void print_file_list(list_t *list);
list_t *get_peer_list(list_t *list,char *nome);




list_t *list_sort_by_ping(list_t *list);
void list_superpeer_copy(list_t *src,list_t *dest );


#endif
